# Maintainer: Peter Budai <peterbudai@hotmail.com>

_realname=scikit-learn
pkgbase=mingw-w64-python2-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}")
pkgver=0.20.3
pkgrel=2
pkgdesc="A set of python modules for machine learning and data mining (mingw-w64)"
arch=('any')
url='http://scikit-learn.sourceforge.net/'
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-python2"
         "${MINGW_PACKAGE_PREFIX}-python2-scipy"
         "${MINGW_PACKAGE_PREFIX}-python2-joblib")
makedepends=("${MINGW_PACKAGE_PREFIX}-python2-setuptools"
             "${MINGW_PACKAGE_PREFIX}-cython2")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/scikit-learn/${_realname}/archive/${pkgver}.tar.gz")
sha256sums=('cadeefa9a824671bdcad790a075efbaa0d5a00458c43c9b4ce7110b129df7b10')

prepare() {
  rm -rf python2-build-${CARCH} | true
  cp -r "${_realname}-${pkgver}" "python2-build-${CARCH}"

  # python -> python2 rename
  find python2-build-${CARCH} -name '*py' -exec sed -e 's_#!/usr/bin/env python_&2_' -i {} \;

}

build() {
  msg "Python 2 build for ${CARCH}"
  cd "${srcdir}/python2-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python2 setup.py build
}

package() {
  cd "${srcdir}/python2-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 COPYING ${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/COPYING

  install -d ${pkgdir}${MINGW_PREFIX}/share/doc/python2-${_realname}
  cp -r doc/tutorial ${pkgdir}${MINGW_PREFIX}/share/doc/python2-${_realname}/tutorial
}
